home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / PRINTING.SWG / 0020_Printer Check Routines.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-17  |  1KB  |  70 lines

  1. PROGRAM PRINTCHK;
  2.  
  3. uses crt,dos,printer;
  4. const
  5.   lpt1=0;
  6.   lpt2=1;
  7.   lpt3=2;
  8.  
  9.   PrnReady = $90;
  10.   OffLine = $00;
  11.   OffLine2 = $10;             {NEW LINE}
  12.   PaperOut = $20;
  13.   PaperOut2 = $30;            {NEW LINE}
  14.   HookedButOff = $80;         {NEW LINE}
  15.   NoConnect = $B0;            {MODIFIED LINE}
  16.  
  17.   {NOCONNECT = $30 FOR SOME COMPUTERS BY STU}
  18.  
  19.   Function ChkPrinter(Printer:Word) :Word;
  20.   Var Regs:Registers;
  21.  
  22.   Begin
  23.     Regs.AH:=2;
  24.     Regs.DX:=Printer;
  25.     Intr($17,regs);
  26.     ChkPrinter:=Regs.AH
  27.   end;
  28.  
  29.   Procedure PrinterError(ErrorCode:BYTE);  ;NEW
  30.  
  31.  
  32.   VAR
  33.     C : BYTE;
  34.  
  35.  
  36.  
  37.   Begin
  38.    ErrorCode := ErrorCode and $B0;       {NEW LINE}
  39.  
  40.    C := ERRORCODE SHL 6   {ALWAYS MEANS NOTHING CONNECTED}
  41.  
  42.    IF C > 0 THEN ERRORCODE = $B0; {ELEMINATES NO LPT3 AND NOTHING CONNECTED}
  43.  
  44.  
  45.    Case ErrorCode of
  46.     NoConnect           : WriteLn('Printer not connected');
  47.     Offline,OffLine2    : WriteLn('Printer off line');     {Modified}
  48.     PaperOut,PaperOut2  : WriteLn('Printer out of paper'); {Modified}
  49.     HookedButOff        : WriteLn('Printer connected but turned off'); {New}
  50.    else
  51.     WriteLn('Printer error code: ',ErrorCode);
  52.    end
  53.   end;
  54.  
  55.   procedure TryPrinter;
  56.   Begin
  57.    {$I-}
  58.    WriteLn(Lst,'Check Printer'+#12);
  59.    {$I+}
  60.    WriteLn(IOResult)
  61.   End;
  62.  
  63.   Begin
  64.    ClrScr;
  65.    {TryPrinter;}
  66.    If ChkPrinter(LPT1) = PrnReady then
  67.     Writeln('Printer is Ready')
  68.    else
  69.     PrinterError(ChkPrinter(LPT1))
  70.   end.